package leetcode.滑动窗口;

public class Leetcode1052 {
    public int maxSatisfied(int[] customers, int[] grumpy, int X) {
        int total = 0;
        for (int i = 0; i < grumpy.length; i++) {
            if(grumpy[i]==0){
                total = total+customers[i];
            }
        }
        int increase = 0;
        for (int i = 0; i < X; i++) {
            increase = increase+grumpy[i]*customers[i];
        }
        int maxIncrease = increase;
        for(int i = X;i<customers.length;i++){
           increase = increase- customers[i-X]*grumpy[i-X] + customers[i]*grumpy[i];
           maxIncrease = Math.max(maxIncrease,increase);
        }
        return total+maxIncrease;
    }
}
